<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html 
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:p="http://primefaces.org/ui"
	lang="en">
	
	
	<ui:decorate template="/WEB-INF/facelets/faceletListar.xhtml">
		<ui:define name="form">
			<h:form>
				<h:messages id="messages" globalOnly="true"
		        	style="border: 1px solid #999999;background-color:#ffffee;padding:6px;font-weight:bold"
		            errorStyle="color:#ff0000;font-weight:bold" layout="table"/>
						
				<fieldset>
					<legend>Filtros da pesquisa</legend>
					<div class="control-group">
						<h:outputLabel value="Ano:" for="ano" styleClass="control-label" />
						<p:inputText id="ano" value="#{RelatorioMB.ano}" maxlength="4" size="4"></p:inputText>  
						
						<h:outputLabel value="Mês:" for="mes" styleClass="control-label" />
						<p:selectOneMenu id="mes" value="#{RelatorioMB.mes}">
										<f:converter converterId="javax.faces.Integer"></f:converter>
										<f:selectItem itemValue="" itemLabel="Todos"></f:selectItem>
										<f:selectItem itemValue="1" itemLabel="Janeiro"></f:selectItem>
										<f:selectItem itemValue="2" itemLabel="Fevereiro"></f:selectItem>
										<f:selectItem itemValue="3" itemLabel="Março"></f:selectItem>
										<f:selectItem itemValue="4" itemLabel="Abril"></f:selectItem>
										<f:selectItem itemValue="5" itemLabel="Maio"></f:selectItem>
										<f:selectItem itemValue="6" itemLabel="Junho"></f:selectItem>
										<f:selectItem itemValue="7" itemLabel="Julho"></f:selectItem>
										<f:selectItem itemValue="8" itemLabel="Agosto"></f:selectItem>
										<f:selectItem itemValue="9" itemLabel="Setembro"></f:selectItem>
										<f:selectItem itemValue="10" itemLabel="Outubro"></f:selectItem>
										<f:selectItem itemValue="11" itemLabel="Novembro"></f:selectItem>
										<f:selectItem itemValue="12" itemLabel="Dezembro"></f:selectItem>
									</p:selectOneMenu>
					</div>
					
					<div class="control-group">
						<p:commandButton action="#{RelatorioMB.pesquisar}" value="Pesquisar" update="tabela, messages"></p:commandButton>
					</div>
				</fieldset>
								
				<p:dataTable 
					id="tabela"
					value="#{RelatorioMB.pagamentos}" 
					var="obj" 
					widgetVar="tabela"
					emptyMessage="Nenhum registro encontrado."
					rowIndexVar="indice">
								
					<p:column>
						<f:facet name="header">
					    	<h:outputText value="Nº" />
					   	</f:facet>
					    <div align="center">
					    	<h:outputText value="#{indice + 1}" />
					    </div>
					</p:column>
					
					<p:column>
				       	<f:facet name="header">
				       		<h:outputText value="Ano" />
				       	</f:facet>
				       	<div align="center">
				        	<h:outputText value="#{obj.ano}" />
				        </div>
				    </p:column>
					        
				    <p:column>
				       	<f:facet name="header">
				       		<h:outputText value="Mês" />
				        </f:facet>
						<div align="center">					           
				        	<h:outputText value="#{obj.mes}" />
				        </div>
				    </p:column>
						        
				    <p:column>
				       	<f:facet name="header">
				       		<h:outputText value="Valor" />
				        </f:facet>
						<div align="center">					           
				        	<h:outputText value="#{obj.valor}" >
				        		<f:convertNumber currencyCode="BRL" type="currency" />
				        	</h:outputText>
				        </div>
				    </p:column>
				    
				    <p:columnGroup type="footer">  
            			<p:row>  
                			<p:column colspan="3" footerText="Total:" style="text-align:right"  />  
                			<p:column footerText="R$ #{RelatorioMB.valorTotal}" />  
                		</p:row>  
        			</p:columnGroup> 
				    				    
			    </p:dataTable>
		</h:form>
	</ui:define>
</ui:decorate>
</html>